package test10;

import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Author czl
 * @Date 2024-04-11
 */
public class MainTest {
    public static void main(String[] args) {
        String name="zhan@qq.com";

        Predicate<String> predicate = (t) -> {
            Pattern pattern = Pattern.compile("^[a-zA-Z0-9_]{5,20}@[a-zA-Z0-9]{2,10}\\.\\w{2,10}$");
            Matcher matcher = pattern.matcher(t);
            return matcher.matches();
        };

        System.out.println(predicate.test(name) ? "email合法" : "email非法");
    }
}
